﻿@using ImoviesBlazorAntPro.Client.Auth
@inject IAuthService AuthService
@inject NavigationManager NavigationManager



<Space Align="center" Style="margin-right: 20px;">
    <SpaceItem>
        <Dropdown Placement="@Placement.Bottom">
            <Overlay>
                <Menu>
                    @* <MenuItem>
                    <IconTemplate>
                    <Icon Type="user" Theme="outline" />
                    </IconTemplate>
                    <ChildContent>个人中心</ChildContent>
                    </MenuItem>
                    <MenuItem>
                    <IconTemplate>
                    <Icon Type="setting" Theme="outline" />
                    </IconTemplate>
                    <ChildContent>个人设置</ChildContent>
                    </MenuItem> *@
                    <MenuItem OnClick="Logout">
                        <IconTemplate>
                            <Icon Type="logout" Theme="outline" />
                        </IconTemplate>
                        <ChildContent>退出登录</ChildContent>
                    </MenuItem>

                </Menu>
            </Overlay>

            <ChildContent>
                <Avatar Size="small" Src="/imgs/logo.png" />
                <span class="name anticon">@username</span>
            </ChildContent>
        </Dropdown>
    </SpaceItem>
</Space>




@code {
    private string username = string.Empty;


    private async Task Logout()
    {
        await AuthService.Logout();
        NavigationManager.NavigateTo("/", true);
    }

    protected override async Task OnInitializedAsync()
    {
        username = await AuthService.GetUserName();
        await base.OnInitializedAsync();
    }
}